{extend name='admin'}
{block name='css'}
<link rel="stylesheet" type="text/css" href="{:asset('bootstrap-3.3.7/css/bootstrap.css')}"/>
{/block}
{block name='content'}
    <ul class="nav nav-tabs">
        <li role="presentation" ><a href="{:url('admin/index/index')}">首页</a></li>
        <li role="presentation" class="active"><a href="#">博文管理</a></li>
    </ul>
    <div class="search-wrap">
        <div class="search-content">
            <form action="{:url('admin/blog/blogsearch')}" method="post">
            <table class="search-tab">
                <tr>
                    <th width="120">选择分类:</th>
                    <td>
                        <select name="id">
                            <option value="">全部</option>
                            {foreach $date as $item}
                            <option name="{$item.id}" value="{$item.id}">{$item.title}</option>
                            {/foreach}
                        </select>
                    </td>
                    <th width="70">关键字:</th>
                    <td><input class="common-text" placeholder="关键字" name="name" type="text"></td>
                    <td><input class="btn btn-primary btn2" id="search" value="查询" type="submit"></td>
                </tr>
            </table>
        </form>
        </div>
    </div>
    <div class="result-wrap">
        <form name="myform" id="myform" method="post">
            <ul class="nav nav-pills">
                <li role="presentation" class="active"><a id="add" href="{:url('admin/blog/blogadd')}">添加文章</a></li>
            </ul>
            <div class="result-content">
                <table class="table table-hover">
                    <tr>
                        <th>标题</th>
                        <th>图片</th>
                        <th>所属分类</th>
                        <th>作者</th>
                        <th>最近更新时间</th>
                        <th>点击数</th>
                        <th>操作</th>
                    </tr>
                    {foreach $dete as $item}
                    <tr>
                        <td >{$item.name}</td>
                        <td>
                            <img src="http://www.blog.com/{$item.image}" width="80px" alt="">
                        </td>
                        <td>{$item.title}</td>
                        <td>{$item.author}</td>
                        <td>{$item.update_time}</td>
                        <td>{$item.click}</td>
                        <td>
                            <a class="btn btn-info link-update" href="{:url('admin/blog/blogupd?id=')}{$item.id}">修改</a>
                            <a id="{$item.id}" class="btn btn-danger link-del" href="#">删除</a>
                        </td>
                    </tr>
                    {/foreach}
                </table>
                <nav aria-label="Page navigation">
                    {$dete|raw}
                </nav>
            </div>
        </form>
    </div>
{/block}
{block name='js'}
<script>
    $(function() {
        $('.link-del').click(function () {
            var id = $(this).attr('id');
            $.ajax({
                url: "{:url('admin/blog/blogdel')}",
                type: 'get',
                data: {id: id},
                dataType: 'json',
                success: function (msg) {
                    if (msg == 1) {
                        layer.alert('删除成功', {icon: 6}, function () {
                            parent.location.reload();
                            window.location.href = "{:url('admin/blog/index')}";
                        })
                    } else {
                        layer.alert('删除失败', {icon: 5})
                    }
                }
            })
        })
    })
</script>
{/block}
{/extend}